import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list: [{
      type: '个人',
      name: '八维',
      code: "110",
      email: '1111100@bawei.com',
      isRequire: false,
      isDefault: true,
      id: 1
    }]
  },
  mutations: {
    ADD_LIST(state, payload) {
      if (payload.isDefault) {
        state.list.unshift(payload)
      } else {
        state.list.push(payload)
      }
    },
    DELETE_LIST(state, payload) {
      state.list = state.list.filter(v => v.id !== payload.id)
    },
    EDIT_LIST(state, payload) {
      const item = state.list.find(v => v.id === payload.id)
      Object.assign(item, payload)
    }
  },
  actions: {
  },
  modules: {
  }
})
